<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>品牌列表 - Powered By ${systemConfig.systemName}</title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <meta name="Author" content="E-SHOP Team" />
    <meta name="Copyright" content="E-SHOP" />
    <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="${base}/res/plugins/kindeditor-4.1.10/themes/default/default.css?v=2014-05-21" />
    <link href="${base}/res/css/common.css" rel="stylesheet" type="text/css" />
    <% include("/_view/common/include.html"){}%>

    <!-- 百度编辑器 -->
    <script type="text/javascript" charset="utf-8" src="${base}/res/plugins/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${base}/res/plugins/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="${base}/res/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>

    <script type="text/javascript" src="${base}/res/plugins/kindeditor-4.1.10/kindeditor-min.js?v=2014-05-21"></script>
    <script type="text/javascript" src="${base}/res/plugins/kindeditor-4.1.10/lang/zh_CN.js?v=2014-05-21"></script>
    <script type="text/javascript" src="${base}/res/plugins/kindeditor-4.1.10/smimage.js"></script>
    <script type="text/javascript" src="${base}https://static.9hive.cn/global/vendor/layer/layer.js"></script>

    <script src="/res/plugins/laydate/laydate.js"></script>
    <style type="text/css">

        *, :before, :after {
            -webkit-box-sizing: border-box;
            box-sizing: content-box;
        }
    </style>
    <!--<script type="text/javascript">
        var ue = UE.getEditor('editor');//初始化
    </script>-->
    <%
    var isAdd = false;
    var isEdit = false;
    if(isEmpty(integralProduct.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
    <div class="path">
        营销商品 &raquo; <%if(isAdd){%>添加商品<%}else{%>编辑商品<%}%>
    </div>
    <form id="inputForm" class="am-form" action="<%if(isAdd){%>${base}/shop/integralProduct/save<%}else{%>${base}/shop/integralProduct/update<%}%>" method="post" onsubmit="return check()">
        <input type="hidden" name="integralProduct.id" value="${integralProduct.id!}" />
        <table class="input tabContent">
            <tr>
                <th>
                    商品名称:
                </th>
                <td>
                    <input type="text" name="integralProduct.name" id="productName" class="formText" placeholder="" value="${integralProduct.name!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    商品编码:
                </th>
                <td>
                    <input type="text" id="productCode" name="integralProduct.productCode" class="formText" value="${integralProduct.productCode!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    首页banner图:
                </th>
                <td>
                    <div id="image_upload" class="">
                        <img upload="image-single" style="max-height:50px;" src="${integralProduct.img!}" alt="" />
                        <input type="hidden" id="productImg"  name="integralProduct.img" value="${integralProduct.img!}"/>
                        <span class="help-inline">
                            <button name="button" class="btn select_img" type="button" style="height: 24px;font-weight: bolder">选择图片</button><span class="help-inline">选择上传图片</span>
                        </span>
                    </div>
                </td>
            </tr>
            <tr>
                <th>
                    列表页展示商品:
                </th>
                <td>
                    <label><input type="radio" name="integralProduct.isMarketable" value="true"<%if (integralProduct.isMarketable! == true){%> checked<%}%> />是</label>
                    <label><input type="radio" name="integralProduct.isMarketable" value="false"<%if (isAdd || integralProduct.isMarketable == false){%> checked<%}%> />否</label>
                </td>
            </tr>
            <tr>
                <th>
                    商品介绍:
                </th>
                <td>
                    <textarea name="integralProduct.description" rows="10" cols="40">${integralProduct.description!}</textarea>
                    <!--<script id="editor" name="integralProduct.description" type="text/plain"  style="height:240px;width:80%">${integralProduct.description!}</script>-->
                </td>
            </tr>
            <tr>
                <th>
                    市场价:
                </th>
                <td>
                    <input type="text" id="marketPrice" name="integralProduct.marketPrice" id="brandName" class="formText" value="${integralProduct.marketPrice!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    兑换所需爱心:
                </th>
                <td>
                    <input type="text" id="needXin" name="integralProduct.needXin" class="formText" value="${integralProduct.needXin!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    剩余库存:
                </th>
                <td>
                    <input type="text" id="store" name="integralProduct.store" class="formText" value="${integralProduct.store!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    用户兑换限制:
                </th>
                <td>
                    <input type="text" id="exchangeLimit" name="integralProduct.exchangeLimit" class="formText" value="${integralProduct.exchangeLimit!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    商品下架时间:
                </th>
                <td>
                    <input type="text" class="laydate-icon" id="end" name="integralProduct.shelfTime" style="width:200px;" value="${integralProduct.shelfTime!}"/>
                    <label class="requireField">*</label>
                </td>
            </tr>
        </table>
        <div class="buttonArea" style="margin-left: 165px;margin-top: 5px;">
            <input type="submit" id="submitbutton" class="button"  value="确  定" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" class="button" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
        </div>
    </form>
</body>
<script>
    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
    };
    laydate(end);
    function check(){
        var regPrice=/^([1-9]\d*(\.\d*[1-9])?)|(0\.\d*[1-9])$/;//大于零的数值
        var regIntegral = /^\+?[1-9]\d*$/;//大于零的正整数
        var productName=$("#productName").val();//商品名称
        var productCode=$("#productCode").val();//商品编码
        var productImg=$("#productImg").val();//首页banner图
        var marketPrice=$("#marketPrice").val();//市场价
        var needXin=$("#needXin").val();//兑换所需心
        var exchangeLimit=$("#exchangeLimit").val();//兑换所需积分
        var store=$("#store").val();//兑换所需积分
        var end=$("#end").val();
        //var brand=$("input[name='brand.orderList']").val();
        var listReg=/^\d*\d*\d+$/;
        if(!productName){
            layer.msg("请输入商品名称!");
            return false;
        }
        if(!listReg.test(productCode) || parseInt(productCode)>999){
            layer.msg("商品编码请输入0-999的正整数!");
            return false;
        }
        if(!productImg){
            layer.msg("请添加首页banner图!");
            return false;
        }
        if(!regPrice.test(marketPrice)){
            layer.msg("市场价请输入大于零的数值!");
            return false;
        }
        if(!regIntegral.test(needXin)){
            layer.msg("兑换所需心请输入大于零的正整数!");
            return false;
        }
        if(!regIntegral.test(exchangeLimit)){
            layer.msg("用户兑换限制请输入大于零的正整数!");
            return false;
        }
        if(!end){
            layer.msg("请选择下架时间!");
            return false;
        }
    }


    KindEditor.ready(function(K){
        var editor = KindEditor.editorObj || K.editor({
                    themeType: 'simple',
                    allowFileManager: true,
                    uploadJson: '${base}/uploadfile/integraluploadpicture?shopId=${shopId!}',
                    fileManagerJson: 'https://www3.weimob.com/resource/imageSingleManage?bid=11933&pid=5883'
                });

        $('#image_upload button.select_img').click(function(e){
            editor.loadPlugin('smimage', function(){
                editor.plugin.imageDialog({
                    imageUrl: $(e.target).parent().prev().val(),
                    showRemote: 1,//体验版 试用版 禁止上传网络图片 weijing.zhou
                    clickFn: function(url, title, width, height, border, align){
                        $(e.target).parent().prev().val(url);

                        if('image-single' == $(e.target).parent().prev().prev().attr('upload')){
                            $(e.target).parent().prev().prev().attr('src', url);
                            $(e.target).parent().prev().prev().attr('alt', url)
                        }

                        editor.hideDialog();
                    }
                });
            });
        });
    });
</script>
</html>